package com.wmm.service.impl;

import com.wmm.common.Product;
import com.wmm.mapper.ProductMapper;
import com.wmm.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Service;

@Service
public class ProductServiceImpl implements ProductService {

    @Autowired
    private ProductMapper productMapper;

    @Autowired
    private KafkaTemplate<String, Integer> kafkaTemplate;

    @Override
    public void insert(Product product) {
        productMapper.insert(product);
        System.out.println("id = " + product.getId());
        // 发送 id 到 kafka
        kafkaTemplate.send("product", product.getId());
    }
}
